package com.android.xk.mask.client

import io.netty.channel.ChannelInitializer
import io.netty.channel.socket.SocketChannel
import io.netty.handler.logging.LogLevel
import io.netty.handler.logging.LoggingHandler

class ClientChannelInitializer : ChannelInitializer<SocketChannel>()
{
    override fun initChannel(ch: SocketChannel)
    {
        val pipeline = ch.pipeline()
        pipeline.addLast(LoggingHandler(LogLevel.INFO))
        pipeline?.addLast(MessageDecoder(), MessageEncoder())
        pipeline?.addLast(TransparentEncoder())
        pipeline?.addLast("serialPortHandler", SerialPortHandler())
        pipeline?.addLast("clientChannelHandler", MessageHandler())
    }
}